<?php


namespace app\service;


use app\dao\RoomTypeDao;
use app\lib\exception\ServiceException;
use think\facade\Db;

class RoomTypeService
{
    private $RoomTypeDao;

    public function __construct()
    {
        $this->RoomTypeDao = new RoomTypeDao();
    }

    public function getRoomType($id){
        return $this->RoomTypeDao->customQuery()->filterById($id)->getOne();
    }

    public function editRoomType($id , $data){
        $editData = [];
        empty($data['type']) || $editData['name'] = $data['type'];
        empty($data['describe']) || $editData['describe'] = $data['describe'];
        return $this->RoomTypeDao->edit($id , $editData);
    }

    public function delRoomType($id){
        $this->RoomTypeDao->delete($id);
    }

    public function addRoomType($name , $describe){
        return $this->RoomTypeDao->save(['name' => $name , 'describe' => $describe]);
    }
}